<?php


namespace App\Tools;


class TxdtTools
{
        /**
         * @Notes:
         * @Author: 遇见
         * @Date: 2022/11/15
         * @Time: 19:54
         * @param $address
         * @return string
         * 获取经纬度
         */
        public  function addressName($address){
            $url = config("Txdt.NameUrl");
            $sprUrl=sprintf($url,$address);
            $getCurl = CurlTools::getUrl($sprUrl);
            return $getCurl['result']['location']['lat'].','.$getCurl['result']['location']['lng'];
        }

        /**
         * @Notes:
         * @Author: 遇见
         * @Date: 2022/11/15
         * @Time: 19:54
         * @param $address
         * @return mixed
         * 获取地理位置
         */
        public function listAddress($address){
            $url = config("Txdt.url");
            $sprUrl=sprintf($url,$address);
            $getCurl = CurlTools::getUrl($sprUrl);
            return $getCurl['result']['address_component'];
        }

        /**
         * @Notes:
         * @Author: 遇见
         * @Date: 2022/11/15
         * @Time: 19:54
         * @param $address
         * @return mixed
         * 获取地理位置
         */
        public static function staticList($address){
            $url = config("Txdt.url");
            $sprUrl=sprintf($url,$address);
            $getCurl = CurlTools::getUrl($sprUrl);
            if(!empty($getCurl['result']['address'])){
                return $getCurl['result']['address'];
            }

        }

        /**
         * @Notes:
         * @Author: 遇见
         * @Date: 2022/11/15
         * @Time: 19:54
         * @param $address
         * @return mixed
         * 获取省
         */
        public static function staticAddressComponent($address){
            $url = config("Txdt.url");
            $sprUrl=sprintf($url,$address);
            $getCurl = CurlTools::getUrl($sprUrl);
            if($getCurl['result']['address_component']['city']){
                return $getCurl['result']['address_component']['city'];
            }

        }
        public static function staticAddressList($address){
            $url = config("Txdt.url");
            $sprUrl=sprintf($url,$address);
            $getCurl = CurlTools::getUrl($sprUrl);
            return $getCurl['result']['address'];
        }
}
